package com.JL.engine.components;

import com.JL.engine.model.HotRectangle;
import com.JL.engine.model.Component;

import java.awt.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class CollisionComponent extends Component {
    private final Map<String, HotRectangle> hotRectangles = new HashMap<>();
    private Enum type;

    public Enum getType(){
        return type;
    }

    public void setType(Enum type) {
        Objects.requireNonNull(type, "碰撞类型不能为null");
        this.type = type;
    }

    public void addHotRectangle(String name, int offsetX, int offsetY, int width, int height) {
        this.addHotRectangle(name, new Rectangle(offsetX, offsetY, width, height));
    }

    public void addHotRectangle(int offsetX, int offsetY, int width, int height) {
        this.addHotRectangle("default", new Rectangle(offsetX, offsetY, width, height));
    }

    public Map<String, HotRectangle> getHotRectangles() {
        return hotRectangles;
    }

    public void addHotRectangle(Rectangle rectangle) {
        this.addHotRectangle("default", rectangle);
    }

    public void addHotRectangle(String name, Rectangle rectangle) {
        Objects.requireNonNull(name, "热区名称不能为null");
        Objects.requireNonNull(rectangle, "热区不能为null");
        hotRectangles.put(name, new HotRectangle(name, rectangle));
    }
}